package com.ruoyi.level.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.level.domain.TVehicleLevel;
import com.ruoyi.level.service.ITVehicleLevelService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 车辆级别Controller
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/level")
public class TVehicleLevelController extends BaseController
{
    @Autowired
    private ITVehicleLevelService tVehicleLevelService;

    /**
     * 查询车辆级别列表
     */
    @RequiresPermissions("level:level:list")
    @GetMapping("/list")
    public TableDataInfo list(TVehicleLevel tVehicleLevel)
    {
        startPage();
        List<TVehicleLevel> list = tVehicleLevelService.selectTVehicleLevelList(tVehicleLevel);
        return getDataTable(list);
    }

    /**
     * 导出车辆级别列表
     */
    @RequiresPermissions("level:level:export")
    @Log(title = "车辆级别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TVehicleLevel tVehicleLevel)
    {
        List<TVehicleLevel> list = tVehicleLevelService.selectTVehicleLevelList(tVehicleLevel);
        ExcelUtil<TVehicleLevel> util = new ExcelUtil<TVehicleLevel>(TVehicleLevel.class);
        util.exportExcel(response, list, "车辆级别数据");
    }

    /**
     * 获取车辆级别详细信息
     */
    @RequiresPermissions("level:level:query")
    @GetMapping(value = "/{levelId}")
    public AjaxResult getInfo(@PathVariable("levelId") Long levelId)
    {
        return success(tVehicleLevelService.selectTVehicleLevelByLevelId(levelId));
    }

    /**
     * 新增车辆级别
     */
    @RequiresPermissions("level:level:add")
    @Log(title = "车辆级别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TVehicleLevel tVehicleLevel)
    {
        return toAjax(tVehicleLevelService.insertTVehicleLevel(tVehicleLevel));
    }

    /**
     * 修改车辆级别
     */
    @RequiresPermissions("level:level:edit")
    @Log(title = "车辆级别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TVehicleLevel tVehicleLevel)
    {
        return toAjax(tVehicleLevelService.updateTVehicleLevel(tVehicleLevel));
    }

    /**
     * 删除车辆级别
     */
    @RequiresPermissions("level:level:remove")
    @Log(title = "车辆级别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{levelIds}")
    public AjaxResult remove(@PathVariable Long[] levelIds)
    {
        return toAjax(tVehicleLevelService.deleteTVehicleLevelByLevelIds(levelIds));
    }
}
